import http from "@utils/request";

import {
    IUsersList,
    IUserListRes,
    IUnitListData,
    IPostPageData,
    IroleApiResponse,
    IUser,
    IUserAdd,
    IUserGetData,
    IUserUpateData,
    IUserDel,
    IUpdate,
    Irole
} from '@interface/systemUser'

//用户列表
export const userPage = (data: IUsersList): Promise<IUserListRes> => {
    return http.get<IUserListRes>('/system_user/page', data)
}


//组织列表
export const unitList = (): Promise<IUnitListData> => {
    return http.get<IUnitListData>('/system_unit/list')
}




//角色列表
export const rolePage = (data: Irole): Promise<IroleApiResponse> => {
    return http.get<IroleApiResponse>('/system_role/page', data)
}




//添加用户
export const userAdd = (data: IUser): Promise<IUserAdd> => {
    return http.post<IUserAdd>('/system_user/', data)
}


//删除用户
export const userDel = (data: string): Promise<IUserDel> => {
    return http.delete<IUserDel>(`/system_user/${data}`)
}



//用户详情
export const userGet = (data: string): Promise<IUserGetData> => {
    return http.get<IUserGetData>(`/system_user/${data}`)
}



//修改用户
export const userUpdate = (data: IUpdate): Promise<IUserUpateData> => {
    return http.put<IUserUpateData>('/system_user/', data)
}

//重置密码

export const userResetPassword = (data: string): Promise<IUserUpateData> => {
    return http.put<IUserUpateData>(`system_user/reset_password/${data}`,)
}
